package com.sixkey.controller.app;


import com.sixkey.entity.User;
import com.sixkey.entity.vo.UpdateUserVo;
import com.sixkey.response.Response;
import com.sixkey.service.IUserService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2023-09-27
 */
@Slf4j
@Validated
@CrossOrigin
@RestController
@RequestMapping("/api/user")
@RequiredArgsConstructor
public class ApiUserController {

    private final IUserService userService;

    /**
     * 修改头像
     * @param updateUserVo
     * @return
     */
    @PutMapping("/update")
    public Response update(@RequestBody @Valid UpdateUserVo updateUserVo){
        log.info("修改头像请求进来");
        userService.apiUpdateUser(updateUserVo);
        return Response.success();
    }

    /**
     * 获取签到用户信息
     * @param
     * @return
     */
    @GetMapping("/sign/{id}")
    public Response getSignUser(@PathVariable("id") int id){
        log.info("获取签到用户信息请求进来");
        List<User> signUser = userService.getSignUser(id);
        return Response.success(signUser);
    }
}
